#include <iostream>
using namespace std;

void deleteItem(int arr[], int& n, int item) {
    int j = 0;
    for (int i = 0; i < n; ++i) {
        if (arr[i] != item) {
            arr[j] = arr[i];
            ++j;
        }
    }
    n = j;
}

int main() {
    int n;
    while (true) {
        cin >> n;
        if (n == 0) break;
        int* arr = new int[n];
        for (int i = 0; i < n; ++i) {
            cin >> arr[i];
        }
        int item;
        cin >> item;
        deleteItem(arr, n, item);
        for (int i = 0; i < n; ++i) {
            cout << arr[i];
            if (i != n - 1) {
                cout << " ";
            }
        }
        cout << endl;
        delete[] arr;
    }
    return 0;
}